package com.tj.view.activity;

import android.graphics.Bitmap;
import android.graphics.Color;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.tj.view.R;
import com.tj.view.tool.DisplayUtil;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * Created by Administrator on 2017/1/19 0019.
 *
 *
 */

public class DisplayShotActivity extends AppCompatActivity {

    private static final String TAG = "DisplayShotActivity";

    @Bind(R.id.image_shot)
    ImageView mImageView;
    @Bind(R.id.btn)
    Button mBtn;
    @Bind(R.id.tv_height)
    TextView mTv_height;
    @Bind(R.id.linear_whole)
    LinearLayout mLinearLayout;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_diaplay_shot);
        ButterKnife.bind(this);

        mTv_height.postDelayed(new Runnable() {
            @Override
            public void run() {
                //由于窗口view的绘制需要一定的时延, 延迟刷新一下
                mTv_height.setText(String.format(getString(R.string.displayShot)
                        , DisplayUtil.getStatusHeight(DisplayShotActivity.this)
                        , DisplayUtil.getTitleHeight(DisplayShotActivity.this)));
            }
        },2000);

        mBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                clickShot();
            }
        });
    }

    public void clickShot(){
        Bitmap bitmap = DisplayUtil.getDisplayShot(this);
        mImageView.setImageBitmap(bitmap);
        mLinearLayout.setBackgroundColor(Color.GRAY);
    }


}
